{template 'common/header'}
{template 'common'}
<ul class="nav nav-tabs">
    <li {if $operation=='display'} class="active" {/if}>
    <a href="{php echo $this->createWebUrl('dest',array('op' =>'display'))}">目的地列表</a>
    </li>
    <li {if empty($dest['id']) && $operation == 'post'} class="active" {/if}>
    <a href="{php echo $this->createWebUrl('dest',array('op' =>'post'))}">添加目的地</a>
    </li>
    {if !empty($dest['id']) && $operation == 'post'}
    <li class="active">
        <a href="{php echo $this->createWebUrl('dest',array('op' =>'post','id'=>$dest['id']))}">编辑目的地</a>
    </li>
    {/if}
</ul>

<!--列表-->
{if $operation == 'display'}
<div class="main panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:30px;">ID</th>
                <th>显示顺序</th>
                <th>缩略图</th>
                <th>所属区域</th>
                <th>名称</th>
                <th>首页显示</th>
                <th>单品数目</th>
                <th>一日游数量</th>
                <th>精品游数量</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $dest}
            <tr>
                <td>{$dest['id']}</td>
                <td>{$dest['sort']}</td>
                <td>
                    <img src="{php echo tomedia($dest['thumb'])}" alt="{$dest['name']}" width="40">
                </td>
                <td>{$dest['region_name']}</td>
                <td>{$dest['name']}</td>
                <td>
                    {php if($dest['is_index']=='0') echo '<span class="label label-default">不显示</span>' }
                    {php if($dest['is_index']=='1') echo '<span class="label label-primary">显示</span>' }
                </td>
                <td>{$dest['single_number']}</td>
                <td>{$dest['oneday_number']}</td>
                <td>{$dest['quality_number']}</td>
                <td style="text-align:left;">
                    <a href="{php echo $this->createWebUrl('dest', array('op' => 'post', 'id' => $dest['id']))}"
                       class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改">
                        <i class="fa fa-edit"></i>
                    </a>
                    <a href="{php echo $this->createWebUrl('dest', array('op' => 'delete', 'id' => $dest['id']))}"
                       class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="删除">
                        <i class="fa fa-times"></i>
                    </a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
        {$pager}
    </div>`
</div>
<script>
    require(['bootstrap'], function ($) {
        $('.btn').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
    });
</script>

<!--增加修改-->
{elseif $operation == 'post'}
<div class="main">
    <form id="form1" action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$dest['id']}"/>
        <div class="panel panel-default">
            <div class="panel-heading">
                目的地设置
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="number" name="sort" class="form-control" value="{$dest['sort']}"/>
                        <span class="help-block">请输入0~255，越大越前</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="region_id">
                        <span style="color:red">*</span>
                        所属区域
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <select name="region_id" id="region_id" class="form-control">
                            <option value="">==请选择所属区域==</option>
                            {loop $regions $region}
                            <option value="{$region['id']}" {if $dest['region_id'] == $region['id']}selected{/if}>{$region['name']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label" for="name">
                        <span style="color:red">*</span>
                        目的地名称
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" id='name' name="name" class="form-control" value="{$dest['name']}"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">
                        <span style="color:red">*</span>
                        目的地缩略图
                    </label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('thumb', $dest['thumb'])}
                        <span class="help-block">图片280*144px</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">目的地展示图</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_multi_image('thumbs', $dest['thumbs'])}
                        <span class="help-block">图片730*350px</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">首页显示</label>
                    <div class="col-sm-9 col-xs-12">
                        <label class='radio-inline'>
                            <input type='radio' name='is_index' value=1' {if $dest['is_index']==1}checked{/if} /> 是
                        </label>
                        <label class='radio-inline'>
                            <input type='radio' name='is_index' value=0' {if $dest['is_index']==0}checked{/if} /> 否
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">单品数目</label>
                    <div class="col-sm-9 col-xs-12">
                        <input class="form-control" value="{$dest['single_number']}" disabled/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">一日游数量</label>
                    <div class="col-sm-9 col-xs-12">
                        <input class="form-control" value="{$dest['oneday_number']}" disabled/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">精品游数量</label>
                    <div class="col-sm-9 col-xs-12">
                        <input class="form-control" value="{$dest['quality_number']}" disabled/>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1"/>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </form>
</div>

<script language='javascript'>
    $(function () {
        $("#form1").submit(function () {
            if ($(":text[name='region_id']").val() == '') {
                Tip.focus("region_id", "请填写目的地所属区域!");
                return false;
            }
            if ($(":text[name='name']").val() == '') {
                Tip.focus("name", "请填写目的地名称!");
                return false;
            }
            if ($(":text[name='thumb']").val() == '') {
                Tip.focus("thumb", "请填上传缩略图!");
                return false;
            }
            return true;
        });
    });
</script>
{/if}
{template 'common/footer'}